package cn.nfwx.tv.fragment.dialog;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import cn.nfwx.tv.R;

/**
 * Created by dell on 2018/1/19.
 */

public class DownLoadNoticeDialogFragment extends CommonDialogFragment {
    protected static final String EXTRA_NAME_CANCELABLE = "cancelable";
    protected TextView btn_cancle,btn_sure;
    protected TextView mMessageTv;
    protected Button mConfirm;
    protected RelativeLayout rl_wifi;
    protected LinearLayout ll_wifi;
    private View.OnClickListener mPositiveListener;


    public static DownLoadNoticeDialogFragment newInstance(boolean cancelable) {
        DownLoadNoticeDialogFragment instance = new DownLoadNoticeDialogFragment();
        Bundle bundle = new Bundle();
        bundle.putBoolean(EXTRA_NAME_CANCELABLE, cancelable);
        instance.setArguments(bundle);
        return instance;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_download_notice;
    }

    /**
     * 是否填满整个屏幕
     */
    protected boolean isMatchParent() {
        return true;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        btn_sure = findView(R.id.btn_sure);
        btn_cancle = findView(R.id.btn_cancle);
        init();
    }

    private void init() {
        //是否允许关闭
        boolean cancelable = getArguments().getBoolean(EXTRA_NAME_CANCELABLE, true);
        setCancelable(cancelable);
        btn_cancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismissAllowingStateLoss();
            }
        });
        btn_sure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismissAllowingStateLoss();
                mPositiveListener.onClick(v);
            }
        });

    }

    @Override
    protected boolean isOutsideTouchable() {
        return true;
    }

    public void setPositiveListener(View.OnClickListener mPositiveListener) {
        this.mPositiveListener = mPositiveListener;
    }
}
